package com.bawei.caohao0802.view.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.Observer
import coil.load
import coil.transform.RoundedCornersTransformation
import com.bawei.caohao0802.MyApp
import com.bawei.caohao0802.R
import com.bawei.caohao0802.databinding.ActivityTvBinding
import com.bawei.caohao0802.viewmodel.TvViewModel
import com.bawei.caohao20240730.base.BaseActivity
import com.shuyu.gsyvideoplayer.GSYVideoManager

class TvActivity : BaseActivity<TvViewModel,ActivityTvBinding>(R.layout.activity_tv) {
    override fun dataObser() {
        mViewModel.zbdata.observe(this, Observer {
            if(it.result!=null){
                mDing.sg.setUp(it.result.liveStreamUrl,false,"")
                mDing.sg.startPlayLogic()
                mDing.img.load(it.result.headPic){
                    transformations(RoundedCornersTransformation(30f))
                }
                mDing.name.text=it.result.nickName
            }
        })
    }

    override fun initView() {
        var id = intent.getIntExtra("id", 0)
        var pwd = intent.getIntExtra("type", 0)
        if(pwd==1){
            mViewModel.getzb(MyApp.userId,MyApp.sessionId,id)
        }else{
            var url="http://10.59.9.24/live-platform/recordVideo/${id}"
            mDing.sg.setUp(url,false,"")
            mDing.sg.startPlayLogic()
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        GSYVideoManager.releaseAllVideos()
    }
}